<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>加入房间</title>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/create_room.css">
    <script src="js/jquery.min.js"></script>
</head>
<body>
    <!-- 导航栏 -->
<div class="nav">
  <a href="#" class="title">分歧终端机</a>
  <!-- 用来占据中间位置 -->
  <span class="spacer"></span>
  <a href="game_hall.html">游戏大厅</a>

  <a href="index.html">注销</a>
  <!-- <a href="#">注销</a> -->
</div>
  <div id = "create">
    <div>
<!-- <form name="create" action="/createroom" method="get"> -->
  <input type="text" class="input-box" placeholder="输入房间号" id="roomid">
  </div>
  <button id="sendButton" onclick="send_roomid()">加入</button>
<!-- </form> -->
</div>


    <script>
function send_roomid() {
    var roomid = jQuery("#roomid");
    // console.log(roomid);
    jQuery.ajax({
      type: "get",
      url: "/joinroom",
      data: { "roomId": roomid.val() },
      success: function (result) {
        if (result != "" && result.code == 200 && result.data != null) {
          //创建成功，跳转到房间页面
          window.location=("/fight_room.html");
        } else {
          alert("加入失败")
        }
      }
    })
}


    </script>
</body>
</html>